//
//  TNMenberDetailViewController.m
//  跑跑快销
//
//  Created by ylife on 14-4-30.
//  Copyright (c) 2014年 ylife. All rights reserved.
//

#import "TNMenberDetailViewController.h"
#import "TNMarkHistoryViewController.h"
#import "TNMemberTeamViewController.h"
#import "YXOrderViewController.h"

@interface TNMenberDetailViewController ()

@end

@implementation TNMenberDetailViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        [self setTitle:@"团员"];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.navigationController.navigationBar.translucent = NO;
    
    isShowDetail = NO;
    
    _menberDetailView = [[TNMemberDetailView alloc]init];
    self.view = _menberDetailView;
    //设置百分比
    [_menberDetailView.circleView setPercent:60 animated:YES];
    
    //设置月目标量
    [_menberDetailView.goalButton setTitle:@"本月目标量：80000元" forState:UIControlStateNormal];
    
    //加载团员电话和头像
    _menberDetailView.headImageView.image = [UIImage imageNamed:@"a.png"];
    _menberDetailView.phoneLable.text = @"18588888888";
    
    //为底部按钮添加事件
    [_menberDetailView.orderButton addTarget:self action:@selector(gotoOrderManagerViewController) forControlEvents:UIControlEventTouchUpInside];
    [_menberDetailView.markButton addTarget:self action:@selector(gotoMarkHistoryViewController) forControlEvents:UIControlEventTouchUpInside];
    [_menberDetailView.teamButton addTarget:self action:@selector(gotoTeamDetailViewController) forControlEvents:UIControlEventTouchUpInside];

    //添加导航栏右键
    UIBarButtonItem *detailButton = [[UIBarButtonItem alloc]initWithTitle:@"本月目标量：80000元" style:UIBarButtonItemStylePlain target:self action:@selector(showDetail)];
    [detailButton setTitle:@"详情 ^"];
    [self.navigationItem setRightBarButtonItem:detailButton];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 按钮事件
- (void)gotoOrderManagerViewController
{
    YXOrderViewController *viewcontroller = [[YXOrderViewController alloc]init];
    [self.navigationController setHidesBottomBarWhenPushed:YES];
    [self.navigationController pushViewController:viewcontroller animated:YES];
}

- (void)gotoMarkHistoryViewController
{
    [self setHidesBottomBarWhenPushed:YES];
    TNMarkHistoryViewController *viewController = [[TNMarkHistoryViewController alloc]init];
    [self.navigationController pushViewController:viewController animated:YES];
}

- (void)gotoTeamDetailViewController
{
    TNMemberTeamViewController *viewcontroller = [[TNMemberTeamViewController alloc]init];
    [self setHidesBottomBarWhenPushed:YES];
    [viewcontroller setTitle:@"团员"];
    [self.navigationController pushViewController:viewcontroller animated:YES];

}

- (void)showDetail
{
    if (!isShowDetail) {
        [_menberDetailView showDetailView];
        [_menberDetailView lowAllViews];
        isShowDetail = !isShowDetail;
    }
    else
    {
        [_menberDetailView hideDetailView];
        [_menberDetailView highAllViews];
        isShowDetail = !isShowDetail;
    }
}
@end
